package com.funsport.common.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;

/**
 * 活动状态枚举
 *
 * @author Fun-Sport Team
 */
@Getter
public enum EventStatus {

    /**
     * 草稿
     */
    DRAFT("draft", "草稿"),

    /**
     * 已发布
     */
    PUBLISHED("published", "已发布"),

    /**
     * 进行中
     */
    ONGOING("ongoing", "进行中"),

    /**
     * 已完成
     */
    COMPLETED("completed", "已完成"),

    /**
     * 已取消
     */
    CANCELLED("cancelled", "已取消");

    @EnumValue
    @JsonValue
    private final String value;

    private final String description;

    EventStatus(String value, String description) {
        this.value = value;
        this.description = description;
    }

    public static EventStatus fromValue(String value) {
        for (EventStatus status : EventStatus.values()) {
            if (status.getValue().equals(value)) {
                return status;
            }
        }
        throw new IllegalArgumentException("无效的活动状态: " + value);
    }
}

